package com.wyp168.leetcode;

/**
 * @ClassName MaxRepeatingSolution
 * @Title TODO
 * @Description TODO
 * @Author wyp168
 * @Date 2022/11/3 00:33
 */
public class MaxRepeatingSolution {

    public static void main(String[] args) {
        MaxRepeatingSolution solution = new MaxRepeatingSolution();

        String sequence = "aaabaaaabaaabaaaabaaaabaaaabaaaaba";
        String pattern = "aaaba";
        System.out.println(solution.maxRepeating(sequence, pattern));


    }


    public int maxRepeating(String sequence, String word) {
        int count = 0;
        String tempSubMaxStr = word;

        while (sequence.contains(tempSubMaxStr)) {
            count++;
            tempSubMaxStr+= word;
        }

        return count;
    }
}
